home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 353_02 / allvehic.cpp < prev    next >
C/C++ Source or Header  |  1992-01-18  |  2KB  |  53 lines

  1.                                   // Chapter 7 - Program 8
  2. #include <iostream.h>
  3. #include "vehicle.h"
  4. #include "car.h"
  5. #include "truck.h"
  6.  
  7.  
  8. main()
  9. {
  10. vehicle unicycle;
  11.  
  12.    unicycle.initialize(1, 12.5);
  13.    cout << "The unicycle has " << 
  14.                                 unicycle.get_wheels() << " wheel.\n";
  15.    cout << "The unicycle's wheel loading is " << 
  16.          unicycle.wheel_loading() << " pounds on the single tire.\n";
  17.    cout << "The unicycle weighs " << 
  18.                              unicycle.get_weight() << " pounds.\n\n";
  19.  
  20. car sedan;
  21.  
  22.    sedan.initialize(4, 3500.0, 5);
  23.    cout << "The sedan carries " << sedan.passengers() << 
  24.                                                     " passengers.\n";
  25.    cout << "The sedan weighs " << sedan.get_weight() << " pounds.\n";
  26.    cout << "The sedan's wheel loading is " << 
  27.                     sedan.wheel_loading() << " pounds per tire.\n\n";
  28.  
  29. truck semi;
  30.  
  31.    semi.initialize(18, 12500.0);
  32.    semi.init_truck(1, 33675.0);
  33.    cout << "The semi weighs " << semi.get_weight() << " pounds.\n";
  34.    cout << "The semi's efficiency is " << 
  35.                           100.0 * semi.efficiency() << " percent.\n";
  36. }
  37.  
  38.  
  39.  
  40.  
  41. // Result of execution
  42. //
  43. // The unicycle has 1 wheel.
  44. // The unicycle's wheel loading is 12.5 pounds on the single tire.
  45. // The unicycle weighs 12.5 pounds.
  46. //
  47. // The sedan carries 5 passengers.
  48. // The sedan weighs 3500 pounds.
  49. // The sedan's wheel loading is 875 pounds per tire.
  50. //
  51. // The semi weighs 12500 pounds.
  52. // The semi's efficiency is 72.929072 percent.
  53.